<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/11/18
 * Time: 15:37
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\common\model\mysql;

class GrabSheet extends Base
{
    public function getGrabOrder(array $where = [], int $limit = 10, int $page = 1, string $field = '*')
    {
        return $this->field($field)
            ->where($where)
            ->order('id desc')
            ->paginate([
                'list_rows' => $limit,
                'var_page' => 'page',
                "page" => $page
            ])
            ->toArray();
    }

    public function getOrderIdAttr($value)
    {
        $order = (new Order())->getBaseById((int)$value);
        return $order;
    }

    public function getGrabUserAttr($value)
    {
        $auth = (new Auth())->getAuthByOpenid($value);
        return $auth;
    }

    public function getGrabOrderByOrderId(int $order_id = 0, string $field = '*')
    {
        return $this
            ->field($field)
            ->where('order_id', $order_id)
            ->find();
    }

}